package org.gpp.proj1.demo.map;

import java.io.IOException;

import org.gpp.proj1.map.GameMap;
import org.gpp.proj1.map.MalformedMapFileException;
import org.gpp.proj1.map.MapNode;
import org.gpp.proj1.map.parser.MapFileParser;
import org.gpp.proj1.map.renderer.MapNodeBuilder;

import com.jme.app.SimpleGame;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;

public class SelectionTilesDemo extends SimpleGame {
	
	public static void main(String[] args) {
		SelectionTilesDemo demo = new SelectionTilesDemo();
		demo.start();
	}

	@Override
	protected void simpleInitGame() {
		this.lightState.setGlobalAmbient( new ColorRGBA( 1.0f, 1.0f, 1.0f, 1.0f ) );
		this.cam.setLocation(new Vector3f(50,180,450));
		this.cam.lookAt(new Vector3f(240,0,280), new Vector3f(0,1,0));
					
		GameMap map = null;
		try {
			map = MapFileParser.parseFile( "res/map/demoMap.map" );
		} catch (IOException e) {
			e.printStackTrace();
		} catch (MalformedMapFileException e) {
			e.printStackTrace();
		}
		
		if( map != null ) {
			MapNode mapNode = MapNodeBuilder.buildNode( map );
			
			ColorRGBA alphaRed = new ColorRGBA( 1.0f, 0.0f, 0.0f, 0.4f );
			mapNode.activateSelectionTiles(16, 8, 3, alphaRed );
						
			ColorRGBA alphaGreen = new ColorRGBA( 0.0f, 1.0f, 0.0f, 0.4f );
			mapNode.activateSelectionTiles(6, 7, 2, alphaGreen );
			
			rootNode.attachChild( mapNode );
		}		
	}
}
